import os
import random
def findAllfile(base):
	for root,ds,fs in os.walk(base):
		for f in fs:
			yield f
base='./images/'
ilist = []


for i in findAllfile(base):
	ilist.append(i)
random.shuffle(ilist)
num = len(ilist)

file_path = 'train.txt'
fo1 = open(file_path, "a+")
file_path = 'test.txt'
fo2 = open(file_path, "a+")
a=0
for line in ilist:
	
	if a < (num*0.2):
		if int(line[1:4]) > 103:
			fo1.write("./images/%s ./annotations/%sxml\n"%(line,line[:-3]))
			print("add ./images/%s ./annotations/%sxml"%(line,line[:-3]))
			continue
		a += 1
		fo2.write("./images/%s ./annotations/%sxml\n"%(line,line[:-3]))
		print("test ./images/%s ./annotations/%sxml"%(line,line[:-3]))
	else :
		fo1.write("./images/%s ./annotations/%sxml\n"%(line,line[:-3]))
		print("train ./images/%s ./annotations/%sxml"%(line,line[:-3]))

fo1.close()
fo2.close()